<?php
/**
 * Created by PhpStorm.
 * User: zhj
 * Date: 2019/3/7
 * Time: 16:39
 */

namespace app\common\model;


class Msg extends ModelBase
{
    public function addMsg($data=[],$user_id=0,$city_id=0)
    {
        $success = ['code'=>1,'msg'=>'留言成功~'];
        $error =  ['code'=>0,'msg'=>'留言失败~'];
        if(!$data || !$user_id || !$city_id){
            return $error;
        }
        $data['user_id'] = $user_id;
        $data['city_id'] = $city_id;
        $res = $this->save($data);
        if($res){
            return $success;
        }else{
            return $error;
        }
    }

    public function getMsgList($where=[],$field="*")
    {
        $where['status'] = 1;
        return $this->where($where)->field($field)->select()->toArray();
    }
}